home *** CD-ROM | disk | FTP | other *** search
- //Ratively backup All Files/Subdir in Directory <Directory2Backup>
- //to <ZipDirectory>
- const Directory2Backup = 'c:\Qzip3\';
- ZipDirectory = 'c:\temp\Qzip3';
- var RootDrive : String;
- procedure RelativeBackup;
- var ParamList,NewFileList : TStringList;
- ZipList : TStringList;
- i,j,k : integer;
- Backup,ZipDir : String;
- fn : string;
- begin
- Backup := Appendslash(Directory2Backup);
- ZipDir := AppendSlash(ZipDirectory);
- ParamList := TStringList.create;
- ZipList := TStringList.create;
- ZipList.Sorted := True;
- NewFileList := TStringList.create;
- NewFilelist.sorted := true;
-
- ParamList.AddStrings(Pollfilelist(Backup+'*.*',True));
- ZipList.AddStrings(Pollfilelist(ZipDir+'Backup*.Zip',False));
- NewFileList.AddStrings(ParamList);
-
- for i := 0 to ZipList.count -1 do
- begin
- open(ZipList.strings[i]);
- for j := 0 to total_Contents -1 do
- begin
- fn := RootDrive+Contents_FileDefpath(j)+Contents_Filename(j);
- if Contents_Filename(j) = ExtractFilename(fn) then
- if Contents_FileSize(j) = getfilesize(fn) then
- if GetFileDatetime(ZipList.strings[i]) > GetFileDatetime(fn) then
- if NewFileList.Find(fn,k) then
- NewFileList.Delete(k);
- end;
- end;
-
- i := 0;
- While FileExists(ZipDir+'Backup'+inttoStr(i)+'.zip') do
- i := i + 1;
-
- UseAddPath(True);
- Open(ZipDir+'Backup'+inttoStr(i)+'.zip');
- For i := 0 to NewFileList.count -1 do
- Add(NewFileList.Strings[i]);
- if NewFilelist.count > 0 then
- DoAdd;
- end;
-
- begin
- RootDrive := Copy(ZipDirectory,1,3);
- RelativeBackup;
- Writeln('Completed!');
- end.
-